home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Mac Magazin/MacEasy 19
/
Mac Magazin and MacEasy Magazine CD - Issue 19.iso
/
Wissenschaft & Technik
/
Alpha
/
Help
/
ElectricAlias Help
< prev
next >
Wrap
Text File
|
1994-06-16
|
9KB
|
286 lines
######### electricAlias Help LAST UPDATE: 01/24/93 9:29:39 AM #########
This help file refers to version 1.7 of electricAlias.tcl
QUICK START
'electricAlias' is a general-purpose Tcl package that provides a
flexible way to automate entering repetitive text. This text can be as
simple as the current date, or can be a template containing many entry
points where additional data is added. In this case, 'electricAlias'
inserts the boilerplate and provides a convenient way to jump between
entry points. Using electricAlias is as simple as typing a key word and
hitting the tab key.
The following instructions will get you up and running ASAP. You will have
three new bindings: 1. <TAB> will be bound to 'electricAlias-insert' and 2.
<control-j> will be bound to 'nextStop', which jumps you to the next entry
point in the current aliased text. 3. <control-shift-j> is bound to
'prevStop', which jumps you to the previous entry point.
$HOME:Tcl:ElectricAlias:Aliases contains default aliases for many modes.
You can modify these or create your own.
To invoke in the current session invoke it from the Utils menu or call
'loadElectricAliases' from you userStartup.tcl file.
Now go read about TEMPLATES below and examine the aliases files
to understand how it all fits together.
GENERAL USAGE
ElectricAlias is simple to use. Normally it is bound to the
<TAB> character, so you just type away. You define aliases
in the alias definitions files $HOME:Tcl:ElectricAlias:aliases:aliases*.
PROCEDURE SYNTAX
electricAlias-insert
Invokes alias template insertion. Text is scanned from
the current cursor position to the beginning of the line.
If the non-whitespace text immediately adjacent has an
alias entry, then template insertion proceeds.
electricAlias-idefine
An interactive mode to define aliases. Crude.
electricAlias-def MODE NAME ?DEFINITION?
Defines or displays an alias template. If DEFINITION
is omitted and the alias exists, then the current
definition is returned per TCL 'return'.
Aliases may have embedded variables, TCL commands, stops,
line-ends and deletes as described under TEMPLATES below.
If MODE begins with a bullet (•), then the alias is only effective
when used as the first token on a line.
electricAlias-undefine MODE NAME
Undefines entry for alias MODE and NAME
electricAlias-exists MODE NAME
Returns 1 if alias NAME exists; otherwise 0.
electricAlias-list ?MODE?
Inserts a sorted list of current definitions.
Specifying a MODE will restrict the returned list to
that mode.
List may be used in another TCL. Uses getalias
proc.
electricAlias-mode ?NAME?
Sets the current alias mode. This is used to determine
which alias to use in a given situation. Leading bullet (•),
if any, is removed. This forces use of the MODE field when
defining aliases that must occur as the first token of a line.
If the NAME is missing, then the current mode is returned.
electricAlias-names ?MODE?
Returns a list of currently defined alias names.
Specifying a MODE will restrict the returned list to
that mode.
electricAlias-off
Turns electricAlias off
electricAlias-on
Turns electricAlias on
electricAlias-iundefine
An interactive mode to remove aliases. Crude.
electricAlias-removeall ?MODE?
Removes all alias definitions and variables
Specifying a MODE will restrict the returned list to
that mode.
electricAlias-var MODE NAME ?DEFINITION?
Defines an alias variable for use in templates. If the pattern
§{NAME} is found during template insertion, it is replaced with
the DEFINITION. This allows a single template to have multiple
uses.
If the DEFINITION is omitted, then the current definition
is returned.
electricAlias-version
Returns the current version info.
TEMPLATE DEFINITIONS
Templates provide a mechanism for inserting text with temporary stops.
Facility is also provided to preserve indentation and allow for alias
variable insertion and TCL commands. This is accomplished with special
character sequences embedded within the template. Hopefully, none of
these are needed in the inserted text itself. Here are the definitions:
\b deletes one character to the left. Useful for outdenting.
• inserts a temporary mark
§«CMD» inserts the results of executing the TCL command CMD. Be
careful if your command contains anything that would be
construed as part of a regular expression. To be safe use
only single procedures with simple arguments. Also, the CMD
may not contain a closing '»'.
It is possible for §«CMD»'s to be recursive (subject to the same
restrictions above) or include §{VAR}'s.
§{VAR} inserts an alias variable (IMPORTANT: inserted AFTER §«CMD»'s)
It is possible for §{VAR}'s to be recursive or include §«CMD»'s
(subject to the §«CMD» restrictions above).
\r inserts a new-line break and cues procedure to preserve indentation
if alias mode is bullet type or when called explicitly.
\n identical to \r
\t inserts a tab for indentation
Other escapes are as defined by TCL
You can trick templates to insert some of the above with the following;
although, why you would want to is beyond me.
'\ \bb' inserts literal '\b'
'§ \b«CMD»' inserts literal '§«CMD»'
'§ \b{VAR}' inserts literal '§{VAR}'
SIMPLE EXAMPLES
The following examples show several templates that might be appropriate
for the C programming language:
electricAlias-def •C while "while (•) {\r\t•\r}/*endwhile*/•"
electricAlias-def •C for "for (•;•;•) {\r\t•\r}/*endfor*/•"
electricAlias-def •C if "if (•) {\r\t•\r}/*endif*/•"
electricAlias-def •C elseif "\b} else if (•) {\r•"
electricAlias-def •C else "\b} else {\r•"
Suppose that the user has an open window for MYFILE.C (please bear
with the poor graphics):
+-------------------
| MYFILE.C
+-------------------
|
+-------------------
By typing 'while\t' this would insert:
+-------------------
| MYFILE.C
+-------------------
|while () {
|
|}/*endwhile*/
+-------------------
The cursor would be positioned inside the parentheses ready for an
expression to be typed. When done with the expression, the user would
press CONTROL-J to jump to the next position where the body of the
WHILE loop would be entered. A final CONTROL-J would position the user
just after the /*endwhile*/ comment.
For this example, suppose the user types 'i < 5';
Suppose the user type 'if\t' inside the body of the while, then we
would get:
+-------------------
| MYFILE.C
+-------------------
|while (i < 5) {
| if () {
|
| }/*endif*/
|}/*endwhile*/
+-------------------
For the IF conditional suppose the user typed '*c != 0'.
Now in the body of the IF the user enters 'a = 1;else\ta = 2' and gets:
+-------------------
| MYFILE.C
+-------------------
|while (i < 5) {
| if (*c != 0) {
| a = 1;
| } else {
| a = 2;
| }/*endif*/
|}/*endwhile*/
+-------------------
Suppose you don't like my indentation style for C. Perhaps the following
definitions and the resulting code would be more suited to your tastes:
electricAlias-def •C while "while (•)\r {\r\t•\r }\r•"
electricAlias-def •C for "for (•;•;•)\r {\r •\r }\r•"
electricAlias-def •C if "if (•)\r {\r •\r }\r•"
electricAlias-def •C elseif "\b\b}\r\b\b\b\belse if (•)\r\b\b{\r•"
electricAlias-def •C else "\b\b}\r\b\b\b\belse\r\b\b{\r•"
Now MYFILE.C would look like this:
+-------------------
| MYFILE.C
+-------------------
|while (i < 5)
| {
| if (*c != 0)
| {
| a = 1;
| }
| else
| {
| a = 2;
| }
|
| }
+-------------------
COPYRIGHT
Copyright © 1993 by David C. Black
All rights reserved.
Redistribution and use in source and binary forms are permitted
provided that the above copyright notice and this paragraph are
duplicated in all such forms and that any documentation,
advertising materials, and other materials related to such
distribution and use acknowledge that the software was developed
by David C. Black.
THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
AUTHOR
David C. Black
Internet: black@mpd.tandem.com
GEnie: D.C.BLACK
USnail: 6217 John Chisum Lane, Austin, Tx 78749-1838
THE END